package com.example.demo.controller;

import com.example.demo.domain.Student;
import com.example.demo.service.StudentService;
//import com.sun.javafx.collections.MappingChange;
//import com.sun.tools.javac.util.List;
//import com.sun.tools.javac.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*" ,methods = {RequestMethod.GET,RequestMethod.POST,RequestMethod.OPTIONS})
public class StudentController {
    @Autowired
    private StudentService studentService;

    @PostMapping("/save")
    public Map save(@RequestParam String number, @RequestParam String password) {
        Student student = new Student();
        student.setNumber(number);
        student.setPassword(password);
        return  this.studentService.sava(student);

    }
    @PostMapping("/login")
    public Map login(@RequestParam String number, @RequestParam String password){
        return  this.studentService.login(number,password);
    }
    @PostMapping("/findall")
    public List findall()
    {
        return this.studentService.findall();
    }
}



